package com.example.block_chain.controller.student;

import com.example.block_chain.common.ResponseResult;
import com.example.block_chain.service.student.StudentService;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;

@RestController
public class StudentController {

    @Autowired
    public StudentService studentService;

    @PostMapping("/student/getAll/")
    public ResponseResult allMessage(@RequestParam String studentId) {
        return studentService.allMessage(studentId);
    }

    @PostMapping("/student/send/award")
    public ResponseResult handleFileUpload(@RequestParam("awardFile") MultipartFile awardFile, HttpSession session) {
        return studentService.handleFileUpload(awardFile,session);
    }

    @PostMapping("/student/batch-create/")
    public ResponseResult batchCreateStudents(@RequestParam("file") MultipartFile file) {
        return studentService.batchCreateStudents(file);
    }
}
